import { text } from 'stream/consumers';
import { viteMockServe } from 'vite-plugin-mock';

const createUserList = () => {
   return [
      {
         severname: 'home-line',
         backgroundColor: '#fff',
         grid: {
            left: '5%',
            right: '5%',
            top: '20%',
            bottom: '5%',
            containLabel: true,
         },
         title: {
            text: '@csentence(4, 6)',
            textStyle: {
               color: '#333',
               fontSize: 18,
            },
         },
         tooltip: {
            show: true,
            trigger: 'item',
         },
         legend: {
            show: true,
            x: 'center',
            y: '35',
            icon: 'stack',
            itemWidth: 10,
            itemHeight: 10,
            textStyle: {
               color: '#1bb4f6',
            },
            data: ['已采纳', '已发布', '浏览量'],
         },
         xAxis: [
            {
               type: 'category',
               boundaryGap: false,
               axisLabel: {
                  color: '#30eee9',
               },
               axisLine: {
                  show: true,
                  lineStyle: {
                     color: '#397cbc',
                  },
               },
               axisTick: {
                  show: false,
               },
               splitLine: {
                  show: true,
                  lineStyle: {
                     color: '#195384',
                  },
               },
               data: '@range(1, 10)',
            },
         ],
         yAxis: [
            {
               type: 'value',
               name: '信息量',
               min: 0,
               max: 1000,
               axisLabel: {
                  formatter: '{value}',
                  textStyle: {
                     color: '#2ad1d2',
                  },
               },
               axisLine: {
                  lineStyle: {
                     color: '#27b4c2',
                  },
               },
               axisTick: {
                  show: false,
               },
               splitLine: {
                  show: true,
                  lineStyle: {
                     color: '#11366e',
                  },
               },
            },
            {
               type: 'value',
               name: '浏览量',
               min: 0,
               max: 1000,
               axisLabel: {
                  formatter: '{value} 人',
                  textStyle: {
                     color: '#186afe',
                  },
               },
               axisLine: {
                  lineStyle: {
                     color: '#186afe',
                  },
               },
               axisTick: {
                  show: false,
               },
               splitLine: {
                  show: true,
                  lineStyle: {
                     color: '#11366e',
                  },
               },
            },
         ],
         series: [
            {
               name: '已采纳',
               type: 'line',
               stack: '总量',
               symbol: 'circle',
               symbolSize: 8,
               itemStyle: {
                  normal: {
                     color: '#0092f6',
                     lineStyle: {
                        color: '#0092f6',
                        width: 1,
                     },
                     areaStyle: {},
                  },
               },
               markPoint: {
                  itemStyle: {
                     normal: {
                        color: 'red',
                     },
                  },
               },
               data: '@range(100, 280, 20)',
            },
            {
               name: '已发布',
               type: 'line',
               stack: '总量',
               symbol: 'circle',
               symbolSize: 8,

               itemStyle: {
                  normal: {
                     color: '#00d4c7',
                     lineStyle: {
                        color: '#00d4c7',
                        width: 1,
                     },
                     areaStyle: {},
                  },
               },
               data: '@range(200, 380, 20)',
            },
            {
               name: '浏览量',
               type: 'line',
               stack: '总量',
               symbol: 'circle',
               symbolSize: 8,
               itemStyle: {
                  normal: {
                     color: '#aecb56',
                     lineStyle: {
                        color: '#aecb56',
                        width: 1,
                     },
                     areaStyle: {},
                  },
               },
               data: '@range(200, 380, 20)',
            },
         ],
      },
      {
         severname: 'home-gantt',
         backgroundColor: '#fff',
         title: {
            text: '@csentence(4, 8)',
            padding: 20,
            textStyle: {
               fontSize: 17,
               fontWeight: 'bolder',
               color: '#333',
            },
            subtextStyle: {
               fontSize: 13,
               fontWeight: 'bolder',
            },
         },
         legend: {
            data: ['计划工期', '可行性研究阶段', '初步设计阶段'],
            align: 'right',
            right: 80,
            top: 50,
         },
         grid: {
            containLabel: true,
            show: false,
            right: 130,
            left: 40,
            bottom: 40,
            top: 90,
         },
         xAxis: {
            type: 'time',
            axisLabel: {
               show: true,
               interval: 0,
            },
         },
         yAxis: {
            axisLabel: {
               show: true,
               interval: 0,
               formatter: null,
            },
            data: ['治理工程', '标段一', '标段二'],
         },
         tooltip: {
            trigger: 'axis',
            formatter: null,
         },
         series: [
            {
               name: '计划工期',
               type: 'bar',
               stack: '总量0',
               label: {
                  normal: {
                     show: true,
                     color: '#000',
                     position: 'right',
                     formatter: function (params) {
                        return params.seriesName;
                     },
                  },
               },
               itemStyle: {
                  normal: {
                     color: 'skyblue',
                     borderColor: '#fff',
                     borderWidth: 2,
                  },
               },
               zlevel: -1,
               data: ['@date("yyyy-MM-dd")', '@date("yyyy-MM-dd")', '@date("yyyy-MM-dd")'],
            },
            {
               name: '计划工期',
               type: 'bar',
               stack: '总量0',
               itemStyle: {
                  normal: {
                     color: 'white',
                  },
               },
               zlevel: -1,
               z: 3,
               data: ['@date("yyyy-MM-dd")', '@date("yyyy-MM-dd")', '@date("yyyy-MM-dd")'],
            },
            {
               name: '可行性研究阶段',
               type: 'bar',
               stack: '总量2',
               label: {
                  normal: {
                     show: true,
                     color: '#000',
                     position: 'right',
                     formatter: function (params) {
                        return params.seriesName;
                     },
                  },
               },
               itemStyle: {
                  normal: {
                     color: 'green',
                     borderColor: '#fff',
                     borderWidth: 2,
                  },
               },
               zlevel: -1,
               data: ['@date("yyyy-MM-dd")', '@date("yyyy-MM-dd")', '@date("yyyy-MM-dd")'],
            },
            {
               name: '可行性研究阶段',
               type: 'bar',
               stack: '总量2',
               itemStyle: {
                  normal: {
                     color: 'white',
                  },
               },
               zlevel: -1,
               z: 3,
               data: ['@date("yyyy-MM-dd")', '@date("yyyy-MM-dd")', '@date("yyyy-MM-dd")'],
            },
            {
               name: '初步设计阶段',
               type: 'bar',
               stack: '总量3',
               label: {
                  normal: {
                     show: true,
                     color: '#000',
                     position: 'right',
                     formatter: function (params) {
                        return params.seriesName;
                     },
                  },
               },
               itemStyle: {
                  normal: {
                     color: 'red',
                     borderColor: '#fff',
                     borderWidth: 2,
                  },
               },
               zlevel: -1,
               data: ['@date("yyyy-MM-dd")', '@date("yyyy-MM-dd")', '@date("yyyy-MM-dd")'],
            },
            {
               name: '初步设计阶段',
               type: 'bar',
               stack: '总量3',
               itemStyle: {
                  normal: {
                     color: 'white',
                  },
               },
               zlevel: -1,
               z: 3,
               data: ['@date("yyyy-MM-dd")', '@date("yyyy-MM-dd")', '@date("yyyy-MM-dd")'],
            },
         ],
      },
      {
         severname: 'home-pie',
         backgroundColor: '#fff',
         title: {
            text: '@csentence(4, 6)',
            left: 'center',
            top: '40%',
            padding: [24, 0],
            textStyle: {
               color: '#333',
               fontSize: 18,
               align: 'center',
            },
         },
         legend: {
            selectedMode: false,
            formatter: null,
            data: '@csentence(4, 6)',
            left: 'center',
            top: 'center',
            icon: 'none',
            align: 'center',
            textStyle: {
               color: '#fff',
               fontSize: 16,
               rich: {},
            },
         },
         series: [
            {
               name: '@csentence(4, 5)',
               type: 'pie',
               radius: ['42%', '50%'],
               hoverAnimation: false,
               color: ['#c487ee', '#deb140', '#49dff0', '#034079', '#6f81da', '#00ffb4'],
               label: {
                  normal: {
                     formatter: null,
                     rich: {
                        yellow: {
                           color: '#ffc72b',
                           fontSize: 26,
                           padding: [5, 4],
                           align: 'center',
                        },
                        total: {
                           color: '#ffc72b',
                           fontSize: 40,
                           align: 'center',
                        },
                        white: {
                           color: '#333',
                           align: 'center',
                           fontSize: 14,
                           padding: [10, 0],
                        },
                        blue: {
                           color: '#49dff0',
                           fontSize: 16,
                           align: 'center',
                        },
                        hr: {
                           borderColor: '#0b5263',
                           width: '100%',
                           borderWidth: 1,
                           height: 0,
                        },
                     },
                  },
               },
               labelLine: {
                  normal: {
                     length: 55,
                     length2: 0,
                     lineStyle: {
                        color: '#0b5263',
                     },
                  },
               },
               data: [
                  {
                     value: '@integer(1000, 5000)',
                     name: '@csentence(4, 8)',
                  },
                  {
                     value: '@integer(1000, 5000)',
                     name: '@csentence(4, 8)',
                  },
                  {
                     value: '@integer(1000, 5000)',
                     name: '@csentence(4, 8)',
                  },
                  {
                     value: '@integer(1000, 5000)',
                     name: '@csentence(4, 8)',
                  },
                  {
                     value: '@integer(1000, 5000)',
                     name: '@csentence(4, 8)',
                  },
                  {
                     value: '@integer(1000, 5000)',
                     name: '@csentence(4, 8)',
                  },
               ],
            },
         ],
      },
   ];
};

export default [
   {
      url: '/mock/dev/lineEchart',
      method: 'post',
      response: ({ body }) => {
         const { severname, type } = body;
         const checkData = createUserList().find((item) => item.severname === severname);
         if (!checkData) {
            return {
               code: 201,
               msg: '获取列表信息失败',
               data: null,
            };
         }
         return {
            code: 200,
            msg: 'success',
            data: checkData,
         };
      },
   },
   {
      url: '/mock/dev/ganttEchart',
      method: 'post',
      response: ({ body }) => {
         const { severname, type } = body;
         const checkData = createUserList().find((item) => item.severname === severname);
         if (!checkData) {
            return {
               code: 201,
               msg: '获取列表信息失败',
               data: null,
            };
         }
         return {
            code: 200,
            msg: 'success',
            data: checkData,
         };
      },
   },
   {
      url: '/mock/dev/pieEchart',
      method: 'post',
      response: ({ body }) => {
         const { severname, type } = body;
         const checkData = createUserList().find((item) => item.severname === severname);
         if (!checkData) {
            return {
               code: 201,
               msg: '获取列表信息失败',
               data: null,
            };
         }
         return {
            code: 200,
            msg: 'success',
            data: checkData,
         };
      },
   },
];
